<?php
namespace app\mini_api\controller;

class Contract extends Permission
{
    public function _initialize()
    {
        parent::_initialize();
        parent::check();
    }

    public function getList()
    {
        $page = isset($this->input_data['page']) ? $this->input_data['page'] : 1;
        $pageSize = isset($this->input_data['pageSize']) ? $this->input_data['pageSize'] : 15;
        $map = [
            'status' => 100,
            'member_id' => $this->user['id']
        ];

        // if(isset($this->input_data['cate']) && $this->input_data['cate'] > 0) $map['cate'] = $this->input_data['cate'];
        $total = db('Trade')->where($map)->count();
        
        $list = db('Trade')->order('id', 'desc')->page($page,$pageSize)->where($map)->select();
        
        
        $data = [
            'total' => $total,
            'list' => $list
        ];
                
        $this->resSuc($data);
    }

    public function getById()
    {
        $map['id'] = $this->input_data['id'];
        $result = db('Trade')->where($map)->find();

        $this->resSuc($result);
    }


}
